<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    二、使用四种方案给以下数组去重
    Let att = [12,45,23,12,56,45,99,100]
</body>

</html>
<script>
    var att = [12, 45, 23, 12, 56, 45, 99, 100]
    // 第一种方案
    let att1 =[...new Set(att)]
    console.log(att1);
    //第二种方案
    var att2 = []
    var flag = true
    for(var i =0;i<att.length;i++){
        flag=true
        for(var j =0;j<att2.length;j++){
            if(att2[j]==att[i]){
                flag=false
            }
        }
        if(flag){
            att2.push(att[i])
        }
    }
    console.log(att2);
    //第三种方案
    var att3 = []
    var obj = {}
    for(var i =0;i<att.length;i++){
        obj[att[i]]="12"
    }
    for(key in obj){
        att3.push(Number(key))
    }
    console.log(att3);

    //第四种方案

    var att4 = []
    for (var i = 0; i < att.length; i++) {
        if (att.lastIndexOf(att[i]) == -1) {
            att4.push(att[i])
        } else {
            if (att4.indexOf(att[i]) == -1) {
                att4.push(att[i])
            }
        }
    }
    console.log(att4);
</script>